#ifndef QLS_QSS_GLOBAL_H
#define QLS_QSS_GLOBAL_H

/* ----- qss属性封装 ----- */
// val, get, set, sig_changed, Q_PROPERTY
#define QLS_PROPERTY(var_, type_)                    \
private:                                             \
    type_ var_;                                      \
                                                     \
public:                                              \
    inline type_ get_##var_() const { return var_; } \
                                                     \
Q_SIGNALS:                                           \
    void sig_##var_##changed();                      \
                                                     \
public Q_SLOTS:                                      \
    void set_##var_(type_ var)                       \
    {                                                \
        var_ = var;                                  \
        update();                                    \
        emit sig_##var_##changed();                  \
    }                                                \
                                                     \
public:                                              \
    Q_PROPERTY(type_ var_ READ get_##var_ WRITE set_##var_)

/* ----- 常用样式组合 ----- */
// normal, hover, check
#define QLS_PROPERTY_NHC(var_, type_)  \
    QLS_PROPERTY(var_##normal_, type_) \
    QLS_PROPERTY(var_##hover_, type_)  \
    QLS_PROPERTY(var_##check_, type_)

// normal, press
#define QLS_PROPERTY_NP(var_, type_)   \
    QLS_PROPERTY(var_##normal_, type_) \
    QLS_PROPERTY(var_##press_, type_)

// normal, hover, press, check, disable
#define QLS_PROPERTY_NHPCD(var_, type_) \
    QLS_PROPERTY(var_##normal_, type_)  \
    QLS_PROPERTY(var_##hover_, type_)   \
    QLS_PROPERTY(var_##press_, type_)   \
    QLS_PROPERTY(var_##check_, type_)   \
    QLS_PROPERTY(var_##disable_, type_)


#endif // QLS_QSS_GLOBAL_H
